<?php include('header.php') ?>

<div id="mainbody"  >
<div class="col-lg-10" id="charge">
<form action="<?=$_SERVER["PHP_SELF"]?>" method="post">
    <table class="table table-bordered" id="work-table">
      <tr id="table-nav"> 
      	<td>卡号</td>
        <td> 姓名</td>
        <td>手机</td>
        <td>操作</td>
      </tr>
      <tr>
       	<td><input type="text" name="sid"></td>
    	<td><input type="text" name="name"></td>
    	<td><input type="text" name="phone"></td>
    	<td><input type="submit" name="submit" value="添加"></td>
       </tr>
   </table>
   
</form>
</div>

  
</div>
<?php
 header('Content-Type: text/html; charset=UTF-8');
 
	if(isset($_POST['submit'])){
		$conn=mysql_connect("localhost","root","1234") or die("数据库连接失败！");
		mysql_select_db('libraryoa') or die("数据库选择失败！");
		mysql_query("set names utf8");
			$name=$_POST['name'];
			$sid=$_POST['sid'];
			$phone=$_POST['phone'];
			$pass=MD5('123456');
			$sql = <<<SQL
			insert into teach (teachid,teachname,teachphone,stillwork,teacherpass) values ("{$sid}","{$name}","{$phone}","yes","{$pass}");
SQL;
	
	$resul=mysql_query($sql) or die("请检查该老师卡号是否有误");
	if($resul){
		echo '<script>alert("成功添加一位老师！");</script>';
		mysql_close();
	}
	}
	?>      
    
<footer>
	<div >
		 <div class="panel panel-default" id="foot" >
      <div class="panel-body" >
        版权信息 © 2014, 云南大学图书馆 
     </div>
</div>
		
	</div>
  </footer>	
   </body>
</html>